<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

function shop_assets($path, $theme) {
    return base_url('assets/template/' . $theme . '/' . $path);
}
function shop_assets_preview($theme) {
    return base_url('assets/template/' . $theme . '/images/preview.jpg');
}
function getShopInfo($shopId) {
    $ci = &get_instance();
    $ci->load->model('repo/shop_model', 'shop_model');
    return $ci->shop_model->getShop($shopId);
}
function getShopUrl($link) {
    $s = str_replace('http://', '', $link);
    $s = str_replace('www.', '', $s);
    $s = str_replace('/', '', $s);
    return $s;
}
function getTemplateName($dir) {
    $ci = &get_instance();
    $ci->load->helper('file');
    return get_filenames($dir);
}
function get_tpl_head($aCss, $aJS, $template=SHOP_DEFAULT_TEMPLATE_NAME) {
    $ci = &get_instance();
    return $ci->load->view('shop-themes/' . $template . '/layout/head.html.php', array('aCSS' => $aCss, 'aJS' => $aJS), true);
}
function get_theme_item($item, $aData=null, $theme=SHOP_DEFAULT_TEMPLATE_NAME) {
    $ci = &get_instance();
    return $ci->load->view("shop-themes/{$theme}/layout/{$item}.html.php", $aData, true);
}
function makeShopImageFolderDir($dir, $arr){
    foreach ($arr as $key => $value) {
        $path = './uploads/public/' . $dir. '/' . $value;
        if (!mkdir($path, 0777, true)) {
            return false;
        } else {
            $html = "<html><head><title>403 Forbidden</title></head><body><p>Directory access is forbidden.</p></body></html>";
            file_put_contents($path.'/index.html' , $html);
        }
    }
    return true;
}

?>